Skip to contentSkip to conversation

Change in openvpn[master]: Multi-socket win: avoid repeated socket_set()

Openvpn-devel In review its_Giaan (Code Review) 4 participants 10 messages Sep 9, 2025 – Sep 12, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1757408812000.Ia389fcec50fb2bbc0aa5ad41a2c23c17c04e6e9b@...2715...

#1 lore raw

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1174?usp=email

to review the following change.

Change subject: Multi-socket win: avoid repeated socket_set()
......................................................................

Multi-socket win: avoid repeated socket_set()

On Windows, multi-socket support failed with
mixed protocols due to repeated socket_set()
calls, which caused accept() to be triggered
before having an event to process.
This fix skips socket_set() calls for
non-UDP sockets in MODE_SERVER inside
multi_io_process_flags().

Change-Id Ia389fcec50fb2bbc0aa5ad41a2c23c17c04e6e9b

---
M src/openvpn/forward.c

1 file changed, 4 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/74/1174/1

src/openvpn/forward.c +4 -1
index 03b6a0c..ce69324 100644
@@ -2124,7 +2124,10 @@
      */
     for (int i = 0; i < c->c1.link_sockets_num; i++)
     {
-        socket_set(c->c2.link_sockets[i], es, socket, &c->c2.link_sockets[i]->ev_arg, NULL);
+        if (c->mode != MODE_SERVER || proto_is_dgram(c->c2.link_sockets[i]->info.proto))
+        {
+            socket_set(c->c2.link_sockets[i], es, socket, &c->c2.link_sockets[i]->ev_arg, NULL);
+        }
     }
 
     tun_set(c->c1.tuntap, es, tuntap, (void *)tun_shift, NULL);

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1174?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia389fcec50fb2bbc0aa5ad41a2c23c17c04e6e9b
Gerrit-Change-Number: 1174
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

Hello flichtenheld, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1174?usp=email

to look at the new patch set (#2).

Change subject: Multi-socket win: avoid repeated socket_set()
......................................................................

Multi-socket win: avoid repeated socket_set()

On Windows, multi-socket support failed with
mixed protocols due to repeated socket_set()
calls, which caused accept() to be triggered
before having an event to process.
This fix skips socket_set() calls for
non-UDP sockets in MODE_SERVER inside
multi_io_process_flags().

Change-Id Ia389fcec50fb2bbc0aa5ad41a2c23c17c04e6e9b

---
M src/openvpn/forward.c

1 file changed, 4 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/74/1174/2

src/openvpn/forward.c +4 -1
index 03b6a0c..1552d39 100644
@@ -2124,7 +2124,10 @@
      */
     for (int i = 0; i < c->c1.link_sockets_num; i++)
     {
-        socket_set(c->c2.link_sockets[i], es, socket, &c->c2.link_sockets[i]->ev_arg, NULL);
+        if ((c->options.mode != MODE_SERVER) || (proto_is_dgram(c->c2.link_sockets[i]->info.proto)))
+        {
+            socket_set(c->c2.link_sockets[i], es, socket, &c->c2.link_sockets[i]->ev_arg, NULL);
+        }
     }
 
     tun_set(c->c1.tuntap, es, tuntap, (void *)tun_shift, NULL);

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1174?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia389fcec50fb2bbc0aa5ad41a2c23c17c04e6e9b
Gerrit-Change-Number: 1174
Gerrit-PatchSet: 2
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

Hello flichtenheld, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1174?usp=email

to look at the new patch set (#3).

Change subject: Multi-socket win: avoid repeated socket_set()
......................................................................

Multi-socket win: avoid repeated socket_set()

On Windows, multi-socket support failed with
mixed protocols due to repeated socket_set()
calls, which caused accept() to be triggered
before having an event to process.
This fix skips socket_set() calls for
non-UDP sockets in MODE_SERVER inside
multi_io_process_flags().

Change-Id Ia389fcec50fb2bbc0aa5ad41a2c23c17c04e6e9b

---
M src/openvpn/forward.c

1 file changed, 6 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/74/1174/3

src/openvpn/forward.c +6 -1
index 03b6a0c..5d22fa3 100644
@@ -2121,10 +2121,15 @@
 
     /*
      * Configure event wait based on socket, tuntap flags.
+     * (for TCP server sockets this happens in
+     *  socket_set_listen_persistent()).
      */
     for (int i = 0; i < c->c1.link_sockets_num; i++)
     {
-        socket_set(c->c2.link_sockets[i], es, socket, &c->c2.link_sockets[i]->ev_arg, NULL);
+        if ((c->options.mode != MODE_SERVER) || (proto_is_dgram(c->c2.link_sockets[i]->info.proto)))
+        {
+            socket_set(c->c2.link_sockets[i], es, socket, &c->c2.link_sockets[i]->ev_arg, NULL);
+        }
     }
 
     tun_set(c->c1.tuntap, es, tuntap, (void *)tun_shift, NULL);

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1174?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia389fcec50fb2bbc0aa5ad41a2c23c17c04e6e9b
Gerrit-Change-Number: 1174
Gerrit-PatchSet: 3
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset

#4 lore raw

I don't have proof of it but I think I was being hit with this accept issue as I've been running and testing OpenVPN in TCP client/server modes only. I'll wait for this to hit master and rebase my PRs - thanks :)

Quoted 67 lines · its_Giaan (Code Review)

Attention is currently required from: flichtenheld, plaisthos.

its_Giaan *uploaded patch set #3* to this change.

View Change <http://gerrit.openvpn.net/c/openvpn/+/1174?usp=email>

Multi-socket win: avoid repeated socket_set()

On Windows, multi-socket support failed with mixed protocols due to repeated socket_set() calls, which caused accept() to be triggered before having an event to process. This fix skips socket_set() calls for non-UDP sockets in MODE_SERVER inside multi_io_process_flags().

Change-Id Ia389fcec50fb2bbc0aa5ad41a2c23c17c04e6e9b

---
M src/openvpn/forward.c

1 file changed, 6 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/74/1174/3

src/openvpn/forward.c +6 -1
index 03b6a0c..5d22fa3 100644
@@ -2121,10 +2121,15 @@
 
     /*
      * Configure event wait based on socket, tuntap flags.
+     * (for TCP server sockets this happens in
+     *  socket_set_listen_persistent()).
      */
     for (int i = 0; i < c->c1.link_sockets_num; i++)
     {
-        socket_set(c->c2.link_sockets[i], es, socket, &c->c2.link_sockets[i]->ev_arg, NULL);
+        if ((c->options.mode != MODE_SERVER) || (proto_is_dgram(c->c2.link_sockets[i]->info.proto)))
+        {
+            socket_set(c->c2.link_sockets[i], es, socket, &c->c2.link_sockets[i]->ev_arg, NULL);
+        }
     }
 
     tun_set(c->c1.tuntap, es, tuntap, (void *)tun_shift, NULL);

To view, visit change 1174
<http://gerrit.openvpn.net/c/openvpn/+/1174?usp=email>. To unsubscribe, or for help writing mail filters, visit settings
<http://gerrit.openvpn.net/settings>.
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia389fcec50fb2bbc0aa5ad41a2c23c17c04e6e9b
Gerrit-Change-Number: 1174
Gerrit-PatchSet: 3
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#5 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, its_Giaan, plaisthos.

stipa has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1174?usp=email )

Change subject: Multi-socket win: avoid repeated socket_set()
......................................................................

Patch Set 3: Code-Review+1

(1 comment)

Patchset:

PS3:
Tested on Windows - indeed before the patch, the server rans into endless loop. Now it works as it should.

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1174?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia389fcec50fb2bbc0aa5ad41a2c23c17c04e6e9b
Gerrit-Change-Number: 1174
Gerrit-PatchSet: 3
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Fri, 12 Sep 2025 06:30:21 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#6 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, its_Giaan, plaisthos.

stipa has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1174?usp=email )

Change subject: Multi-socket win: avoid repeated socket_set()
......................................................................

Patch Set 3: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1174?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia389fcec50fb2bbc0aa5ad41a2c23c17c04e6e9b
Gerrit-Change-Number: 1174
Gerrit-PatchSet: 3
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: its_Giaan <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Fri, 12 Sep 2025 06:51:34 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#7 lore raw

PATCH v3 1/1 Multi-socket win: avoid repeated socket_set()

In reply to a message not in the archive

From: Gianmarco De Gregori <[email protected]...>

On Windows, multi-socket support failed with
mixed protocols due to repeated socket_set()
calls, which caused accept() to be triggered
before having an event to process.
This fix skips socket_set() calls for
non-UDP sockets in MODE_SERVER inside
multi_io_process_flags().

Change-Id Ia389fcec50fb2bbc0aa5ad41a2c23c17c04e6e9b

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1174
This mail reflects revision 3 of this Change.

Acked-by according to Gerrit (reflected above):
Lev Stipakov <[email protected]...>

src/openvpn/forward.c +6 -1
index 03b6a0c..5d22fa3 100644
@@ -2121,10 +2121,15 @@
 
     /*
      * Configure event wait based on socket, tuntap flags.
+     * (for TCP server sockets this happens in
+     *  socket_set_listen_persistent()).
      */
     for (int i = 0; i < c->c1.link_sockets_num; i++)
     {
-        socket_set(c->c2.link_sockets[i], es, socket, &c->c2.link_sockets[i]->ev_arg, NULL);
+        if ((c->options.mode != MODE_SERVER) || (proto_is_dgram(c->c2.link_sockets[i]->info.proto)))
+        {
+            socket_set(c->c2.link_sockets[i], es, socket, &c->c2.link_sockets[i]->ev_arg, NULL);
+        }
     }
 
     tun_set(c->c1.tuntap, es, tuntap, (void *)tun_shift, NULL);
#8 lore raw

[Openvpn-devel] [PATCH applied] Re: Multi-socket win: avoid repeated socket_set()

I can't claim I understand what exactly upsets what here, but since Gianmarco is the "multi event expert" and Lev has confirmed that this fixes the observed windows issues, *and* there is now a comment that explains to casual readers what this is about, good enough for me :-) (plus the CI infra agrees that things still work).

Again, mail-archive.org claims this was never sent to the list, so linking to sf.net archive & our gerrit.

Your patch has been applied to the master branch.

commit 3b429925fb9b4a822facc6ea9f13b927b6021944

Author: Gianmarco De Gregori
Date:   Fri Sep 12 15:12:07 2025 +0200
     Multi-socket win: avoid repeated socket_set()

     Signed-off-by: Gianmarco De Gregori <[email protected]...>
     Acked-by: Lev Stipakov <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://sourceforge.net/p/openvpn/mailman/message/59232443/
     URL: https://gerrit.openvpn.net/c/openvpn/+/1174
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#9 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#4) to the change originally created by its_Giaan. ( http://gerrit.openvpn.net/c/openvpn/+/1174?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by stipa

Change subject: Multi-socket win: avoid repeated socket_set()
......................................................................

Multi-socket win: avoid repeated socket_set()

On Windows, multi-socket support failed with mixed protocols due to repeated socket_set() calls, which caused accept() to be triggered before having an event to process. This fix skips socket_set() calls for non-UDP sockets in MODE_SERVER inside multi_io_process_flags().

Change-Id Ia389fcec50fb2bbc0aa5ad41a2c23c17c04e6e9b

Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59232443/
URL: https://gerrit.openvpn.net/c/openvpn/+/1174

---
M src/openvpn/forward.c

1 file changed, 6 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/74/1174/4

src/openvpn/forward.c +6 -1
index 03b6a0c..5d22fa3 100644
@@ -2121,10 +2121,15 @@
 
     /*
      * Configure event wait based on socket, tuntap flags.
+     * (for TCP server sockets this happens in
+     *  socket_set_listen_persistent()).
      */
     for (int i = 0; i < c->c1.link_sockets_num; i++)
     {
-        socket_set(c->c2.link_sockets[i], es, socket, &c->c2.link_sockets[i]->ev_arg, NULL);
+        if ((c->options.mode != MODE_SERVER) || (proto_is_dgram(c->c2.link_sockets[i]->info.proto)))
+        {
+            socket_set(c->c2.link_sockets[i], es, socket, &c->c2.link_sockets[i]->ev_arg, NULL);
+        }
     }
 
     tun_set(c->c1.tuntap, es, tuntap, (void *)tun_shift, NULL);

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1174?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia389fcec50fb2bbc0aa5ad41a2c23c17c04e6e9b
Gerrit-Change-Number: 1174
Gerrit-PatchSet: 4
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#10 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1174?usp=email )

Change subject: Multi-socket win: avoid repeated socket_set()
......................................................................

Multi-socket win: avoid repeated socket_set()

On Windows, multi-socket support failed with mixed protocols due to repeated socket_set() calls, which caused accept() to be triggered before having an event to process. This fix skips socket_set() calls for non-UDP sockets in MODE_SERVER inside multi_io_process_flags().

Change-Id Ia389fcec50fb2bbc0aa5ad41a2c23c17c04e6e9b

Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59232443/
URL: https://gerrit.openvpn.net/c/openvpn/+/1174

---
M src/openvpn/forward.c

1 file changed, 6 insertions(+), 1 deletion(-)
src/openvpn/forward.c +6 -1
index 03b6a0c..5d22fa3 100644
@@ -2121,10 +2121,15 @@
 
     /*
      * Configure event wait based on socket, tuntap flags.
+     * (for TCP server sockets this happens in
+     *  socket_set_listen_persistent()).
      */
     for (int i = 0; i < c->c1.link_sockets_num; i++)
     {
-        socket_set(c->c2.link_sockets[i], es, socket, &c->c2.link_sockets[i]->ev_arg, NULL);
+        if ((c->options.mode != MODE_SERVER) || (proto_is_dgram(c->c2.link_sockets[i]->info.proto)))
+        {
+            socket_set(c->c2.link_sockets[i], es, socket, &c->c2.link_sockets[i]->ev_arg, NULL);
+        }
     }
 
     tun_set(c->c1.tuntap, es, tuntap, (void *)tun_shift, NULL);

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1174?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia389fcec50fb2bbc0aa5ad41a2c23c17c04e6e9b
Gerrit-Change-Number: 1174
Gerrit-PatchSet: 4
Gerrit-Owner: its_Giaan <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged